// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Distributed Cloud Edge Container API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_edgecontainer_v1::client::EdgeContainer;
/// let client = EdgeContainer::builder().build().await?;
/// // use `client` to make requests to the Distributed Cloud Edge Container API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// EdgeContainer API provides management of Kubernetes Clusters on Google Edge
/// Cloud deployments.
///
/// # Configuration
///
/// To configure `EdgeContainer` use the `with_*` methods in the type returned
/// by [builder()][EdgeContainer::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://edgecontainer.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::edge_container::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::edge_container::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `EdgeContainer` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `EdgeContainer` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct EdgeContainer {
    inner: std::sync::Arc<dyn super::stub::dynamic::EdgeContainer>,
}

impl EdgeContainer {
    /// Returns a builder for [EdgeContainer].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_edgecontainer_v1::client::EdgeContainer;
    /// let client = EdgeContainer::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::edge_container::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::edge_container::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::EdgeContainer + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::EdgeContainer>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::EdgeContainer> {
        super::transport::EdgeContainer::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::EdgeContainer> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::EdgeContainer::new)
    }

    /// Lists Clusters in a given project and location.
    pub fn list_clusters(&self) -> super::builder::edge_container::ListClusters {
        super::builder::edge_container::ListClusters::new(self.inner.clone())
    }

    /// Gets details of a single Cluster.
    pub fn get_cluster(&self) -> super::builder::edge_container::GetCluster {
        super::builder::edge_container::GetCluster::new(self.inner.clone())
    }

    /// Creates a new Cluster in a given project and location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_cluster(&self) -> super::builder::edge_container::CreateCluster {
        super::builder::edge_container::CreateCluster::new(self.inner.clone())
    }

    /// Updates the parameters of a single Cluster.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_cluster(&self) -> super::builder::edge_container::UpdateCluster {
        super::builder::edge_container::UpdateCluster::new(self.inner.clone())
    }

    /// Upgrades a single cluster.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn upgrade_cluster(&self) -> super::builder::edge_container::UpgradeCluster {
        super::builder::edge_container::UpgradeCluster::new(self.inner.clone())
    }

    /// Deletes a single Cluster.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_cluster(&self) -> super::builder::edge_container::DeleteCluster {
        super::builder::edge_container::DeleteCluster::new(self.inner.clone())
    }

    /// Generates an access token for a Cluster.
    pub fn generate_access_token(&self) -> super::builder::edge_container::GenerateAccessToken {
        super::builder::edge_container::GenerateAccessToken::new(self.inner.clone())
    }

    /// Generates an offline credential for a Cluster.
    pub fn generate_offline_credential(
        &self,
    ) -> super::builder::edge_container::GenerateOfflineCredential {
        super::builder::edge_container::GenerateOfflineCredential::new(self.inner.clone())
    }

    /// Lists NodePools in a given project and location.
    pub fn list_node_pools(&self) -> super::builder::edge_container::ListNodePools {
        super::builder::edge_container::ListNodePools::new(self.inner.clone())
    }

    /// Gets details of a single NodePool.
    pub fn get_node_pool(&self) -> super::builder::edge_container::GetNodePool {
        super::builder::edge_container::GetNodePool::new(self.inner.clone())
    }

    /// Creates a new NodePool in a given project and location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_node_pool(&self) -> super::builder::edge_container::CreateNodePool {
        super::builder::edge_container::CreateNodePool::new(self.inner.clone())
    }

    /// Updates the parameters of a single NodePool.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_node_pool(&self) -> super::builder::edge_container::UpdateNodePool {
        super::builder::edge_container::UpdateNodePool::new(self.inner.clone())
    }

    /// Deletes a single NodePool.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_node_pool(&self) -> super::builder::edge_container::DeleteNodePool {
        super::builder::edge_container::DeleteNodePool::new(self.inner.clone())
    }

    /// Lists Machines in a given project and location.
    pub fn list_machines(&self) -> super::builder::edge_container::ListMachines {
        super::builder::edge_container::ListMachines::new(self.inner.clone())
    }

    /// Gets details of a single Machine.
    pub fn get_machine(&self) -> super::builder::edge_container::GetMachine {
        super::builder::edge_container::GetMachine::new(self.inner.clone())
    }

    /// Lists VPN connections in a given project and location.
    pub fn list_vpn_connections(&self) -> super::builder::edge_container::ListVpnConnections {
        super::builder::edge_container::ListVpnConnections::new(self.inner.clone())
    }

    /// Gets details of a single VPN connection.
    pub fn get_vpn_connection(&self) -> super::builder::edge_container::GetVpnConnection {
        super::builder::edge_container::GetVpnConnection::new(self.inner.clone())
    }

    /// Creates a new VPN connection in a given project and location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_vpn_connection(&self) -> super::builder::edge_container::CreateVpnConnection {
        super::builder::edge_container::CreateVpnConnection::new(self.inner.clone())
    }

    /// Deletes a single VPN connection.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_vpn_connection(&self) -> super::builder::edge_container::DeleteVpnConnection {
        super::builder::edge_container::DeleteVpnConnection::new(self.inner.clone())
    }

    /// Gets the server config.
    pub fn get_server_config(&self) -> super::builder::edge_container::GetServerConfig {
        super::builder::edge_container::GetServerConfig::new(self.inner.clone())
    }

    /// Lists information about the supported locations for this service.
    pub fn list_locations(&self) -> super::builder::edge_container::ListLocations {
        super::builder::edge_container::ListLocations::new(self.inner.clone())
    }

    /// Gets information about a location.
    pub fn get_location(&self) -> super::builder::edge_container::GetLocation {
        super::builder::edge_container::GetLocation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::edge_container::ListOperations {
        super::builder::edge_container::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::edge_container::GetOperation {
        super::builder::edge_container::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn delete_operation(&self) -> super::builder::edge_container::DeleteOperation {
        super::builder::edge_container::DeleteOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::edge_container::CancelOperation {
        super::builder::edge_container::CancelOperation::new(self.inner.clone())
    }
}
